<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">汇总</block>
		</cu-custom>
		<view>
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in navCur" :key="index" @tap="tabSelect" :data-id="index">
						{{navCur[index]}}
					</view>
				</view>
			</scroll-view>
			<view class="padding flex justify-between">
				<text class="text-xs">数量<text class="text-xxl">{{person}}</text>人</text>
				<text class="text-xs">总额<text class="text-xxl">{{total}}</text>元</text>
			</view>
			<view class="cu-list menu-avatar">
				<view class="cu-item" v-for="(item,index) in month" :key="index">
					<view class="cu-avatar round lg bg-olive">{{item.username.substr(1,1)}}</view>
					<view class="content">
						<view class="text-grey cuIcon-friendaddfill">{{item.username}}</view>
						<view class="text-gray text-sm flex">
							<view class="text-cut">
								<text class="cuIcon-moneybagfill margin-right-xs">工资：</text>
								<text class="text-red text-xl">{{item.wage}}</text>
							</view> </view>
					</view>
					<view class="action">
						<view class="cu-tag round bg-blue sm" @click="change(item.personnel_id)">详情</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				TabCur: 0,
				navCur:['本月','上月'],
				month:'',
				total:0.00,
				person:0
			}
		},
		onLoad() {
			this.toMonth()
		},
		methods:{
			change(id){
				uni.navigateTo({
					url:'/pages/user/detail?id='+id+'&nav='+this.TabCur
				})
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.toMonth()
				console.log(this.TabCur)
			},
			// 汇总
			toMonth: async function(){
				let result = await this.$api.sheetmonth({navc:this.TabCur});
				if(result.code == 1){
					this.month = result.data.data
					this.total = result.data.total
					this.person = result.data.person
				}else{
					this.month = null
					this.total = 0.00
					this.person = 0
				}
			},
		}
		
	}
</script>

<style>
</style>
